package com.smartstate.EnvironmentMonitor.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Random;

@RequestMapping("/data")
@Api(tags = "曲线返回数据")
@RestController
@Slf4j
public class DataController {


    @Resource
    private RedisTemplate redisTemplate;

    /**
     * 获取设备树
     * url: /buildingModel/selectBuilding
     */

    /**
     * 每秒发送实时数据
     */
//    @Scheduled(cron = "*/1 * * * * ?")
//    public void getRealTime(){
//        WebSocketDataServer.sendInfo(redisTemplate);
//    }
//


//    @Scheduled(cron = "*/1 * * * * ?")
//    public void getRealTimeTasktest(){
//        redisTemplate.opsForHash().put("DHU0005","dewpoint", String.valueOf(new Random().nextInt(10)));
//        redisTemplate.opsForHash().put("DHU0005","huminity",String.valueOf(new Random().nextInt(10)));
//        redisTemplate.opsForHash().put("DHU0005","temperature", String.valueOf(new Random().nextInt(10)));
//        redisTemplate.opsForHash().put("DHU0005","littleparticle",String.valueOf(new Random().nextInt(10)));
//        redisTemplate.opsForHash().put("DHU0005","longparticle",String.valueOf(new Random().nextInt(10)));
//        redisTemplate.opsForHash().put("DHU0005","staticpressure",String.valueOf(new Random().nextInt(10)));
//
//    }

}
